// var wxAddress = "http://ydche.com";
// var wxAddress = "http://mobile.ydche.com";
// var wxAddress = "http://wx.ydche.com";
 var wxAddress = "http://176k5907u4.imwork.net";
//var wxAddress = "http://qa.mobile.ydche.com";

/*
 * 定义提示窗蒙层，方法名：warnText()
 * 参数说明：
 * selector：蒙层元素   textValue：提示文本   showTime：显示时间
 */
function warnText(selector,textValue,showTime){
	selector.text(textValue);
	var promptmsgw = "-"+selector.outerWidth()/2+"px";
	selector.css("margin-left", promptmsgw);
	selector.css("top", "50%");
	selector.css("left", "50%");
	selector.fadeIn();
	timer = setTimeout(function(){
		clearInterval(timer);
		selector.fadeOut();
	},showTime)
}

/*
 * Jquery Ajax二次封装，方法名ajaxEncapsulation()
 * 参数说明：
 * url：接口请求地址   successCallBack：成功回调函数   errorCallBack：失败回调函数
 * type：请求类型"GET"或者"POST"，默认"GET"   async：是否异步   data：传递参数
 * dataType：参数类型   contentType：内容编码类型   timeout：响应失效时间，默认不失效，值为0
 * 正常ajax返回内容编码类型：application/x-www-form-urlencoded; charset=utf-8
 * 填写选择后项数值：false undefined null 0 -0 NaN "" ''
 */
function ajaxEncapsulation(url, successCallBack, errorCallBack, type, async, data, dataType, contentType, timeout, callBack){
	var type = (type == null || type == "" || typeof(type) == "undefined" || type == "GET" || type == "get") ? "GET" : type;
	if (async == "true") {
		async = true;
	}else if (async == "false") {
		async = false;
	};
	var data = (data == null || data == "" || typeof(data) == "undefined" || data == {}) ? {} : data;
	var dataType = (dataType == null || dataType == "" || typeof(dataType) == "undefined" || dataType == "json") ? "json" : dataType;
	var contentType = (contentType == null || contentType == "" || typeof(contentType) == "undefined" || contentType == "application/x-www-form-urlencoded; charset=utf-8") ? "application/x-www-form-urlencoded; charset=utf-8" : contentType;
	var timeout = (timeout == null || timeout == "" || typeof(timeout) == "undefined" || timeout == "0") ? "0" : timeout;
	var postValue = data;
	$.ajax({
		type: type,
		async: async,
		url: url,
		data: data,
		dataType: dataType,
		contentType: contentType,
		timeout: timeout,
		success: function(data) {
			successCallBack(data, postValue);
		},
		error: function(data) {
			if(errorCallBack && errorCallBack != "" && typeof(errorCallBack) == "function"){
				errorCallBack(data, postValue);
			}
		}
	})
}

/*
 * 常用正则表达式验证规则
 * 说明：phoneReg-手机格式   idCardReg-身份证格式   postCodeReg-邮编格式
 * passwordReg-密码格式 /^(13[0-9]|15[012356789]|18[0-9]|14[57]|17[0123678])[0-9]{8}$/
 * sharePhoneReg-分享人手机格式   emailReg-邮箱正则   licenseNoReg-车牌正则
 * frameNo 车架号正则   phoneCodeReg-验证码正则
 */
var regs = {
	phoneReg: /^1[3|4|5|7|8][0-9]\d{8}$/,
	idCardReg: /(^\d{15}$)|(^\d{17}([0-9]|X|x)$)/,
	postCodeReg: /^[1-9]\d{5}$/,
	passwordReg: /^.{6,20}$/,
	sharePhoneReg: /^1[3|4|5|8|7][0-9]\d{8}$/,
	emailReg: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
	licenseNoReg: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
	frameNo: /^([0-9A-Z]){17}$/,
	phoneCodeReg: /^\d{6}$/
}

/*
 * 设置提示框遮罩层高度
 */
var maskHeight = $(window).height();
$(".masklayer").css("height", maskHeight);

/*
 * 阻止遮罩层默认滚动事件
 */
$(".masklayer").bind("touchmove",function(e){
	e.preventDefault();
});